//
//  YHBaseTableViewController.swift
//  YHWeibo
//
//  Created by 昱含 on 16/5/20.
//  Copyright © 2016年 YuHan. All rights reserved.
//

import UIKit

class YHBaseTableViewController: UITableViewController,YHVisitorLoginViewDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    //定义用户是否登录
    var userLogin = YHUserAccountViewModel.sharedAccountViewModel.userLogin
    //    var userLogin = true
    lazy var visitorLoginView: YHVisitorLoginView = YHVisitorLoginView()
    
    override func loadView() {
        
        if userLogin {
            
            super.loadView()
            
        }else{
            
            self.loadVisitorView()
            
        }
    }
    
    private func loadVisitorView() {
        
//        let v = YHVisitorLoginView()
//                v.backgroundColor = UIColor.orangeColor()

        view = visitorLoginView
        visitorLoginView.visitorDelegate = self
    }
    
    func userWillLogin() {
        
        let oauth = YHOAuthViewController()
        
        let nav = UINavigationController(rootViewController: oauth)
        
        presentViewController(nav, animated: true, completion: nil)
        
//        print("login")
    }
    
    func userWillRegister() {
        
//        print("register")
    }


    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
